//
//  willShowCell.m
//  MTime
//
//  Created by Carl_fang on 15/3/31.
//  Copyright (c) 2015年 Carl_fang. All rights reserved.
//

#import "willShowCell.h"
#import "UIImageView+WebCache.h"

@interface willShowCell()

@property (nonatomic ,retain) UIImageView *movieImg;

@property (nonatomic, retain) UILabel *titleLabel;
@property (nonatomic, retain) UILabel *wantedCountLabel;
@property (nonatomic, retain) UILabel *director;
@property (nonatomic, retain) UILabel *rDayLabel;

@end


@implementation willShowCell


- (void)setModel:(WillShowModel *)model
{
    
    
    

    //NSLog(@"%f %f",self.imageView.frame.size.width,self.imageView.frame.size.height);
    self.titleLabel.text = model.title;
    NSString *temStr = [NSString stringWithFormat:@"%@人想看 - %@",model.wantedCount,model.type];
    self.wantedCountLabel.text = temStr;
    self.director.text = [NSString stringWithFormat:@"导演:%@",model.director];
    if (model.rDay < 9) {
        self.rDayLabel.text = [NSString stringWithFormat:@"0%d日",model.rDay];
    }else
    {
        self.rDayLabel.text = [NSString stringWithFormat:@"%d日",model.rDay];
    }
    
    
    NSURL *url = [NSURL URLWithString:model.image];
    [self.movieImg setImageWithURL:url];

    
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        CGFloat leftPadding = 10;
        CGFloat topPadding = 10;
        CGFloat margin = 10;
        CGFloat rDayW = 30;
        CGFloat rDayH = 50;
        _rDayLabel = [[UILabel alloc] initWithFrame:CGRectMake(leftPadding, topPadding, rDayW, rDayH)];
        _rDayLabel.font = [UIFont systemFontOfSize:13];
        [self.contentView addSubview:_rDayLabel];
        
        
        CGFloat picW = 70;
        CGFloat picH = 100;
        self.movieImg = [[UIImageView alloc] initWithFrame:CGRectMake(50, 20, picW, picH)];
        
        [self.contentView addSubview:_movieImg];
        //_movieImg.contentMode = UIViewContentModeScaleAspectFit;
        
        //_movieImg.backgroundColor = [UIColor blueColor];
        
        
        
        CGFloat titleW = 200;
        CGFloat titleH = 30;
        _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_movieImg.frame) + margin, topPadding, titleW, titleH)];
        _titleLabel.font = [UIFont boldSystemFontOfSize:18];
        //_titleLabel.backgroundColor = [UIColor orangeColor];
        [self.contentView addSubview:_titleLabel];
        
        
        _wantedCountLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_movieImg.frame) + margin, CGRectGetMaxY(_titleLabel.frame) + margin, titleW, titleH)];
        _wantedCountLabel.font = [UIFont systemFontOfSize:14];
//        _wantedCountLabel.font = [UIFont boldSystemFontOfSize:16];
        _wantedCountLabel.textColor = [UIColor redColor];
        //_wantedCountLabel.backgroundColor = [UIColor blackColor];
        [self.contentView addSubview:_wantedCountLabel];

        _director = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_movieImg.frame) + margin, CGRectGetMaxY(_wantedCountLabel.frame) + margin, titleW, titleH)];
        
        //_director.backgroundColor = [UIColor redColor];
        
        [self.contentView addSubview:_director];

    }
    
    return self;
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
